# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=rita
pkgver=v5.1.0.r2.gfd1bbe3
pkgrel=1
epoch=3
pkgdesc='Real Intelligence Threat Analytics.'
arch=('x86_64')
groups=('blackarch' 'blackarch-recon')
url='https://github.com/activecm/rita'
license=('GPL3')
depends=('bro' 'mongodb')
makedepends=('git' 'go')
source=("git+https://github.com/activecm/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

build() {
  cd $pkgname

  VERSION=$(git describe --abbrev=0 --tags)
  EXACT_VERSION=$(git describe --always --long --dirty --tags)

  GOPATH="$srcdir" go mod download
  GOPATH="$srcdir" go build \
    -trimpath \
    -buildmode=pie \
    -mod=readonly \
    -modcacherw \
    -ldflags "-s -w -X github.com/activecm/rita/config.Version=${VERSION} -X github.com/activecm/rita/config.ExactVersion=${EXACT_VERSION}" \
    -o $pkgname .
}

package() {
  cd $pkgname

  install -Dm 755 $pkgname "$pkgdir/usr/bin/$pkgname"
  #install -Dm 666 "etc/$pkgname.yaml" "$pkgdir/etc/$pkgname/config.yaml"
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" docs/*
}

